﻿﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Xml.Serialization;
using XCode;
using XCode.Configuration;
using XCode.DataAccessLayer;

namespace NewsPub
{
    /// <summary>新闻信息</summary>
    [Serializable]
    [DataObject]
    [Description("新闻信息")]
    [BindIndex("PK_Details", true, "ID")]
    [BindIndex("IX_Details_ClassisID", false, "ClassisID")]
    [BindRelation("ClassisID", false, "Classis", "ID")]
    [BindTable("Details", Description = "新闻信息", ConnName = "NewsPub", DbType = DatabaseType.SqlServer)]
    public partial class Details<TEntity> : IDetails
    {
        #region 属性
        private Int32 _ID;
        /// <summary>编号</summary>
        [DisplayName("编号")]
        [Description("编号")]
        [DataObjectField(true, true, false, 10)]
        [BindColumn(1, "ID", "编号", null, "int", 10, 0, false)]
        public virtual Int32 ID
        {
            get { return _ID; }
            set { if (OnPropertyChanging("ID", value)) { _ID = value; OnPropertyChanged("ID"); } }
        }

        private Int32 _ClassisID;
        /// <summary>分类ID</summary>
        [DisplayName("分类ID")]
        [Description("分类ID")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(2, "ClassisID", "分类ID", null, "int", 10, 0, false)]
        public virtual Int32 ClassisID
        {
            get { return _ClassisID; }
            set { if (OnPropertyChanging("ClassisID", value)) { _ClassisID = value; OnPropertyChanged("ClassisID"); } }
        }

        private Int32 _UserID;
        /// <summary>用户编号</summary>
        [DisplayName("用户编号")]
        [Description("用户编号")]
        [DataObjectField(false, false, false, 10)]
        [BindColumn(3, "UserID", "用户编号", null, "int", 10, 0, false)]
        public virtual Int32 UserID
        {
            get { return _UserID; }
            set { if (OnPropertyChanging("UserID", value)) { _UserID = value; OnPropertyChanged("UserID"); } }
        }

        private String _Title;
        /// <summary>分类名称</summary>
        [DisplayName("分类名称")]
        [Description("分类名称")]
        [DataObjectField(false, false, false, -1)]
        [BindColumn(4, "Title", "分类名称", null, "nvarchar(MAX)", 0, 0, true)]
        public virtual String Title
        {
            get { return _Title; }
            set { if (OnPropertyChanging("Title", value)) { _Title = value; OnPropertyChanged("Title"); } }
        }

        private String _Body;
        /// <summary>内容</summary>
        [DisplayName("内容")]
        [Description("内容")]
        [DataObjectField(false, false, false, 1073741823)]
        [BindColumn(5, "Body", "内容", null, "ntext", 0, 0, true)]
        public virtual String Body
        {
            get { return _Body; }
            set { if (OnPropertyChanging("Body", value)) { _Body = value; OnPropertyChanged("Body"); } }
        }

        private String _Tag;
        /// <summary>InnoDBfree:29696kB</summary>
        [DisplayName("InnoDBfree:29696kB")]
        [Description("InnoDBfree:29696kB")]
        [DataObjectField(false, false, false, -1)]
        [BindColumn(6, "Tag", "InnoDBfree:29696kB", null, "nvarchar(MAX)", 0, 0, true)]
        public virtual String Tag
        {
            get { return _Tag; }
            set { if (OnPropertyChanging("Tag", value)) { _Tag = value; OnPropertyChanged("Tag"); } }
        }

        private DateTime _CreateTime;
        /// <summary>生成时间</summary>
        [DisplayName("生成时间")]
        [Description("生成时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(7, "CreateTime", "生成时间", null, "datetime", 3, 0, false)]
        public virtual DateTime CreateTime
        {
            get { return _CreateTime; }
            set { if (OnPropertyChanging("CreateTime", value)) { _CreateTime = value; OnPropertyChanged("CreateTime"); } }
        }

        private DateTime _EditTime;
        /// <summary>编辑时间</summary>
        [DisplayName("编辑时间")]
        [Description("编辑时间")]
        [DataObjectField(false, false, false, 3)]
        [BindColumn(8, "EditTime", "编辑时间", null, "datetime", 3, 0, false)]
        public virtual DateTime EditTime
        {
            get { return _EditTime; }
            set { if (OnPropertyChanging("EditTime", value)) { _EditTime = value; OnPropertyChanged("EditTime"); } }
        }

        private Int32 _Hits;
        /// <summary>点击数</summary>
        [DisplayName("点击数")]
        [Description("点击数")]
        [DataObjectField(false, false, true, 10)]
        [BindColumn(9, "Hits", "点击数", "0", "int", 10, 0, false)]
        public virtual Int32 Hits
        {
            get { return _Hits; }
            set { if (OnPropertyChanging("Hits", value)) { _Hits = value; OnPropertyChanged("Hits"); } }
        }
		#endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// 一个索引，基类使用反射实现。
        /// 派生实体类可重写该索引，以避免反射带来的性能损耗
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                    case "ID" : return _ID;
                    case "ClassisID" : return _ClassisID;
                    case "UserID" : return _UserID;
                    case "Title" : return _Title;
                    case "Body" : return _Body;
                    case "Tag" : return _Tag;
                    case "CreateTime" : return _CreateTime;
                    case "EditTime" : return _EditTime;
                    case "Hits" : return _Hits;
                    default: return base[name];
                }
            }
            set
            {
                switch (name)
                {
                    case "ID" : _ID = Convert.ToInt32(value); break;
                    case "ClassisID" : _ClassisID = Convert.ToInt32(value); break;
                    case "UserID" : _UserID = Convert.ToInt32(value); break;
                    case "Title" : _Title = Convert.ToString(value); break;
                    case "Body" : _Body = Convert.ToString(value); break;
                    case "Tag" : _Tag = Convert.ToString(value); break;
                    case "CreateTime" : _CreateTime = Convert.ToDateTime(value); break;
                    case "EditTime" : _EditTime = Convert.ToDateTime(value); break;
                    case "Hits" : _Hits = Convert.ToInt32(value); break;
                    default: base[name] = value; break;
                }
            }
        }
        #endregion

        #region 字段名
        /// <summary>取得新闻信息字段信息的快捷方式</summary>
        public class _
        {
            ///<summary>编号</summary>
            public static readonly Field ID = FindByName("ID");

            ///<summary>分类ID</summary>
            public static readonly Field ClassisID = FindByName("ClassisID");

            ///<summary>用户编号</summary>
            public static readonly Field UserID = FindByName("UserID");

            ///<summary>分类名称</summary>
            public static readonly Field Title = FindByName("Title");

            ///<summary>内容</summary>
            public static readonly Field Body = FindByName("Body");

            ///<summary>InnoDBfree:29696kB</summary>
            public static readonly Field Tag = FindByName("Tag");

            ///<summary>生成时间</summary>
            public static readonly Field CreateTime = FindByName("CreateTime");

            ///<summary>编辑时间</summary>
            public static readonly Field EditTime = FindByName("EditTime");

            ///<summary>点击数</summary>
            public static readonly Field Hits = FindByName("Hits");

            static Field FindByName(String name) { return Meta.Table.FindByName(name); }
        }
        #endregion
    }

    /// <summary>新闻信息接口</summary>
    public partial interface IDetails
    {
        #region 属性
        /// <summary>编号</summary>
        Int32 ID { get; set; }

        /// <summary>分类ID</summary>
        Int32 ClassisID { get; set; }

        /// <summary>用户编号</summary>
        Int32 UserID { get; set; }

        /// <summary>分类名称</summary>
        String Title { get; set; }

        /// <summary>内容</summary>
        String Body { get; set; }

        /// <summary>InnoDBfree:29696kB</summary>
        String Tag { get; set; }

        /// <summary>生成时间</summary>
        DateTime CreateTime { get; set; }

        /// <summary>编辑时间</summary>
        DateTime EditTime { get; set; }

        /// <summary>点击数</summary>
        Int32 Hits { get; set; }
        #endregion

        #region 获取/设置 字段值
        /// <summary>
        /// 获取/设置 字段值。
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        Object this[String name] { get; set; }
        #endregion
    }
}